package android.FiltrosJava;

public class BorderTransparency extends TransparencyMask{		
	protected boolean directionVertical = true;
	public BorderTransparency(){
		super(0.0f,1.0f,0,0,0);
	}

	public float[][] computeMask(int dimX, int dimY){
		int centerX = (int) Math.ceil(dimX / 2.0f);
		int centerY = (int) Math.ceil(dimY / 2.0f);
		double menor = Math.min(minT, maxT);
		double maior = Math.max(minT, maxT);		
		double intervalY = (maior - menor)/ centerY;
		double intervalX = (maior - menor)/ centerX;
		double transparencyX, transparencyY;
		float[][] mask = new float[dimY][dimX];
		float d;
		
		transparencyY = menor;
		for ( int y = 0; y < centerY; y++ ) {
			transparencyX = menor;
	    	for ( int x = 0; x < centerX; x++ ) {
	    		d = (float) Math.min(transparencyX,transparencyY);
	    			    		
	    		mask[y][x] = d;
	    		mask[dimY- y -1][x] = d;
	    		mask[y][dimX - x - 1] = d;
	    		mask[dimY - y - 1][dimX - x - 1] = d;
	    		
	    		transparencyX += intervalX;
	    		if (transparencyX > maior)
	    			transparencyX = maior; 
	    	}       		    		
	    	transparencyY += intervalY;
	    	if (transparencyY > maior)
    			transparencyY = maior; 
		}		
		return mask;		
	}	
}
